/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ADT;

import static ADT.Values.*;
/**
 *
 * @author Martin
 */
public class MassInKg extends Scalar implements Mass{
    private final double kilogramm;
    
    @Override public boolean isValid() {return true;}
    @Override public boolean isZero() {return kilogramm == 0.0;}
    
    public MassInKg(double kilogramm) {
    this.kilogramm = kilogramm;
    }
    
    @Override
    public double kg(){
    return kilogramm;
}
    
    @Override
    public double g(){
        return kilogramm * KILO;
    }
    
    @Override
    public Mass inverse(){return valueOf(this.kilogramm * -1);}
    
    @Override
    public Mass add(Mass mass){return valueOf(this.kilogramm + mass.kg());}
    
    @Override
    public Mass sub(Mass mass){return valueOf(this.kilogramm - mass.kg());}
    
    @Override
    public double div(Mass mass){return this.kilogramm / mass.kg();}
    
    
    @Override
    public Mass div(double factor){return valueOf(this.kilogramm / factor);}
    
    @Override
    public Mass mul(double factor){return valueOf(this.kg() * factor);}
    
    @Override 
    public Force mul(Acc acc) {return forceInN(kilogramm * acc.mss());}
    
           //Vergleichbarkeit
    @Override
        public int compareTo(Mass mass) {return Double.compare(this.kg(), mass.kg());}

        @Override
        public boolean equals(Object o) {
                if (o == this)
                        return true;
                if (!(o instanceof LengthInM))
                        return false;
                return this.compareTo((MassInKg) o) == 0;
        }

        @Override
        public String toString() {
                return String.format("%.2d kg", this.kg());
        }
    public static MassInKg valueOf(double kilogramm){
        return new MassInKg(kilogramm);
    }
    
    @Override
    public int hashCode(){
        return hashDouble(kilogramm);
    }
    
}
